package com.herench.bs.handler;

import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by ThinkPad on 2018/3/8.
 */

@Component
@Handler(code = "101104" ,name="支付动态配置")
public class PayChannelConfigHandler extends AbstractMessageHandler {

    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String channelCode = requestMessage.getArgsPropertyStringValue("sysCode");
        List<Map<String,Object>> resultList= new ArrayList<>();

        if (channelCode.equals("100101")){
            Map<String,Object> alipayMap = new HashMap<>();
            alipayMap.put("code", "1");
            alipayMap.put("name","支付宝");
            alipayMap.put("status","0");


            Map<String,Object> weipayMap = new HashMap<>();
            alipayMap.put("code", "2");
            alipayMap.put("name","微信支付");
            alipayMap.put("status","1");
            resultList.add(alipayMap);
        }
        if (channelCode.equals("100102")){
            Map<String,Object> alipayMap = new HashMap<>();
            alipayMap.put("code", "1");
            alipayMap.put("name","支付宝");
            alipayMap.put("status","1");


            Map<String,Object> weipayMap = new HashMap<>();
            weipayMap.put("code", "2");
            weipayMap.put("name","微信支付");
            weipayMap.put("status","0");
            resultList.add(alipayMap);
        }

        responseMessage.setDataAttribute("payList",resultList);
        responseMessage.setCode("0");
        responseMessage.setMessage("请求成功");
        return responseMessage;
    }


}
